import {dialogHidden,dialogShow} from './dialog'
import {wanSet} from './api'

export const TYPE_SWITCH = "TYPE_SWITCH"
export const NET_SUBMIT_START = "NET_SUBMIT_START"
export const NET_SUBMIT_END="NET_SUBMIT_END"
export const NET_SUBMIT_RECEIVE="NET_SUBMIT_RECEIVE"
export const NET_SUBMIT_ERROR = "NET_SUBMIT_ERROR"
export const NET_CLEAR_ERROR = "NET_CLEAR_ERROR"


export const typeSwitch=(net)=>{
    return {
        type:TYPE_SWITCH,
        data:net
    }
}
export const netSubmitStart=()=>{
    return {
        type:NET_SUBMIT_START
    }
}
export const netSubmitEnd=()=>{
    return {
        type:NET_SUBMIT_END
    }
}
export const netSubmitReceive=(data)=>{
    return {
        type:NET_SUBMIT_RECEIVE,
        data
    }
}
export const netSubmitError=(data)=>{
    return {
        type:NET_SUBMIT_ERROR,
        data
    }
}
export const netclearError=()=>{
    return {
        type:NET_CLEAR_ERROR
    }
}
export const netSubmitRequest=()=>{
    return (dispatch,getState)=>{
        dispatch(netSubmitStart())
        wanSet('',{},(data)=>{
            if(data){
                dispatch(netSubmitEnd())
                dispatch(netSubmitReceive(data))
                dispatch(netSubmitError("设置失败"))
            }
            else {
                dispatch(netSubmitError('wan设置失败'))
            }

        })
    }
}






